package com.spring.takeaway.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spring.takeaway.dao.UserDao;
import com.spring.takeaway.po.User;
import com.spring.takeaway.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.math.BigInteger;
import java.util.Queue;

/**
 * @Author LCD
 * @Date 2022/6/13 23:08
 **/
@Service
public class UserServiceImpl implements UserService {
   @Autowired
   private UserDao userDao;

    @Override
    public User findUserByPhone(String phone,String password) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("phone",phone);
        wrapper.eq("password",password);
        return this.userDao.selectOne(wrapper);
    }

    @Override
    public User findUserById(String phone) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("phone",phone);
        return this.userDao.selectOne(wrapper);
    }

    @Override
    public int UpdatePwd(String phone, String pwd) {
        QueryWrapper wrapper1 = new QueryWrapper();
        wrapper1.eq("phone",phone);
        User user = this.userDao.selectOne(wrapper1);
        user.setPassword(pwd);
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("phone",phone);
        return this.userDao.update(user,wrapper);
    }
}
